package com.feihong.txgw.tx_model;

import com.feihong.txgw.http.HttpTools;
import com.feihong.txgw.inter.contract.adr.IDeliveryAdrContract;
import com.feihong.txgw.model.base_bean.BaseResponse;
import com.feihong.txgw.utils.helper.RxHelper;
import com.feihong.txgw.utils.manage.RetrofitManager;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;

/**
 * @Author wangziheng
 * @ProjectName txgw_app
 * @ClassName DeliveryAdrMainModel
 * @package com.feihong.txgw.tx_model
 * @data 2018/5/7 19:25
 * @Describe
 * @Change
 */
public class DeliveryAdrMainModel implements IDeliveryAdrContract.IDeliveryAdrMainModel {

    public static DeliveryAdrMainModel create(){
        return new DeliveryAdrMainModel();
    }

    @Override
    public Observable<String> getDeliveryAdrInfo() {
        return RetrofitManager.getInstance().getUserDeliveryAdr().compose(RxHelper.<String>rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse> delDeliveryAdr(String adrID) {
        Map<String,String> mParams = new HashMap<>();
        mParams.put("addr_id",adrID);
        return RetrofitManager.getInstance().editUserDeliveryAdr(HttpTools.ADR_EDIT_DEL,mParams).compose(RxHelper.<BaseResponse>rxSchedulerHelper());
    }
}
